import requests


class IhrmEmpCURD(object):
    # 添加员工
    @classmethod
    def add_emp(cls, header, json_data):
        url = "https://ihrm-java.itheima.net/api/sys/user"
        resp = requests.post(url=url, headers=header, json=json_data)
        return resp

    # 查询员工
    @classmethod
    def query_emp(cls, emp_id, header):
        url = "https://ihrm-java.itheima.net/api/sys/user/" + emp_id
        resp = requests.get(url=url, headers=header)
        return resp

    # 修改员工
    @classmethod
    def modify_emp(cls, emp_id, header, modify_data):
        url = "https://ihrm-java.itheima.net/api/sys/user/" + emp_id
        modify_data = {"username": "陈菲菲"}
        resp = requests.put(url=url, headers=header, json=modify_data)
        return resp

    # 删除员工
    @classmethod
    def delete_emp(cls, emp_id, header):
        url = "https://ihrm-java.itheima.net/api/sys/user/" + emp_id
        modify_data = {"username": "陈菲菲"}
        resp = requests.delete(url=url, headers=header)
        return resp
if __name__ == '__main__':
    header={"Content-Type":"application/json",
                "Authorization":"Bearer 861ad16a-8159-438a-a056-4dcba966ee8d"}
    data_add={
        "username":"陈菲跃",
        "mobile":"18478834724",
        "workNumber":"9525"
    }
    resp=IhrmEmpCURD.add_emp(header,data_add)
    print(resp.json())
